package api

import (
	"github.com/gin-gonic/gin"
	"shop-api/internal/server"
)

func GoodList(c *gin.Context) {
	type GoodList struct {
		Offset  uint   `json:"offset"`
		Limit   uint   `json:"limit"`
		TypeID  uint   `json:"type_id"`
		Keyword string `json:"keyword"`
	}

	req := new(GoodList)
	if err := c.ShouldBindJSON(&req); err != nil {
		Resp(c, nil, err)
		return
	}

	info, err := server.GetGoodList(req.Offset, req.Limit, req.TypeID, req.Keyword)
	if err != nil {
		Resp(c, nil, err)
		return
	}
	Resp(c, info, nil)
	return
}
